package com.dykj.fireFighting.server.base.bigdata.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.dykj.fireFighting.api.base.bigdata.rcxc.entity.PatrolReportRecord;
import com.dykj.fireFighting.api.base.bigdata.rcxc.service.IPatrolReportRecordService;
import com.dykj.fireFighting.api.base.bigdata.rcxc.vo.PatrolReportRecordVo;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.server.base.bigdata.mapper.PatrolReportRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * 巡更报告记录表
 *
 * @Author JacksonTu
 * @Date  2021-07-05 15:22:53
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class PatrolReportRecordServiceImpl extends BaseServiceImpl<PatrolReportRecordMapper, PatrolReportRecord> implements IPatrolReportRecordService {

    @Override
    public List<PatrolReportRecordVo> reportRecordStatistics(HashMap<String, Object> params) {
        // TODO: 2021-09-23  由于类型改表，前端统计需要改动 换成注释里语句
        /**
          return this.baseMapper.reportRecordStatisticsMonth(params);
         */
        return this.baseMapper.reportRecordStatistics(params);
    }

    @Override
    public void updatePatrolReportRecord(PatrolReportRecord patrolReportRecord) {
        UpdateWrapper<PatrolReportRecord> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("patrol_report_id", patrolReportRecord.getPatrolReportId());
        updateWrapper.eq("device_id", patrolReportRecord.getDeviceId());
        PatrolReportRecord prr = new PatrolReportRecord();
        prr.setIsReport(1);
        this.baseMapper.update(prr, updateWrapper);
    }
}
